package com.peng.crm.workbench.controller;

import com.peng.crm.commons.utils.Result;
import com.peng.crm.workbench.service.ClueActivityRelationService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 线索备注(clueActivityRelation)表控制层
 *
 * @author makejava
 * @since 2022-07-02 19:11:30
 */
@RestController
@RequestMapping("/clueActivityRelation")
public class ClueActivityRelationController {
    /**
     * 服务对象
     */
    @Resource
    private ClueActivityRelationService clueActivityRelationservice;


    /**
     *  查询已关联的市场活动信息
     * @param pageNumber    页码
     * @param pageSize      条数
     * @param clueId        线索ID
     * @return
     */
    @GetMapping("/pagelistactivity")
    public Result pagelistactivity(@RequestParam(value = "pageNumber",defaultValue = "1") Integer pageNumber,
                           @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize,String clueId) {
        return Result.success(clueActivityRelationservice.pagelistactivity(pageNumber,pageSize,clueId));
    }

    /**
     * 查询未关联的市场活动信息
     * @param name 市场活动名称
     * @param clueId 线索Id
     * @return 查询结果
     */
    @GetMapping("/pagelist")
    public Result pagelist(@RequestParam(value = "pageNumber",defaultValue = "1") Integer pageNumber,
                           @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize,String name,String clueId) {
        return Result.success(clueActivityRelationservice.selectList(pageNumber,pageSize,name,clueId));
    }


    /**
     * 解除关联数据
     *
     * @param id 主键标识
     * @return 解除是否成功
     */
    @DeleteMapping("/deleteById/{id}")
    public Result deleteById(@PathVariable("id") String id) {
        return Result.success(clueActivityRelationservice.deleteById(id));
    }

    /**
     * 关联单条或多条数据
     *
     * @param clueId 线索ID
     * @param activityId 市场活动ID
     * @return 关联是否成功
     */
    @PostMapping("/inserts")
    @ResponseBody
    public Result inserts(String clueId, String[] activityId) {
        return Result.success(clueActivityRelationservice.inserts(clueId,activityId));
    }


}

